<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAppSourceConfigsTable extends Migration
{
    private const TABLE = 'app_source_configs';

    public function up()
    {
        if (Schema::connection('gameCenter')->hasTable(self::TABLE)) {
            return ;
        }
        Schema::connection('gameCenter')->create(self::TABLE, function (Blueprint $table) {
            $table->id();
            $table->string('name')->comment('方案名称');
            $table->json('configs')->comment('配置 JSON对象');
            $table->json('sources')->comment('关联渠道');
            $table->timestamps();
        });

        DB::connection('gameCenter')->statement("ALTER TABLE `tb_".self::TABLE."` comment '渠道方案配置'");
    }

    public function down()
    {
        Schema::connection('gameCenter')->dropIfExists(self::TABLE);
    }
}
